﻿using EONFULLSIN2.Models.Dto.Device;
using EONFULLSIN2.Models.Enum.IOPointEnum;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EONFULLSIN2.Services.Device
{
    /// <summary>
    /// IAdamCom通信服务接口
    /// </summary>
    public interface IAdamComBaseServices
    {
        /// <summary>
        /// Com口名称
        /// </summary>
        string COMName { get; }

        /// <summary>
        /// 是否打开
        /// </summary>
        bool IsOpen { get; }

        /// <summary>
        /// AdamIOPoints
        /// </summary>
        List<eIOPointEnum> AdamIOPoints { get; }

        /// <summary>
        /// 连接
        /// </summary>
        /// <returns></returns>
        Task<bool> OpenComAsync();

        /// <summary>
        /// 关闭连接
        /// </summary>
        /// <returns></returns>
        Task<bool> CloseComAsync();

        /// <summary>
        /// 开始读取DO通道状态
        /// </summary>
        /// <returns></returns>
        Task StartReadDOChannelStatusAsync();

        /// <summary>
        /// 停止读取DO通道状态
        /// </summary>
        /// <returns></returns>
        Task<bool> StopReadDOChannelStatusAsync();

        /// <summary>
        /// 获取DO状态数据
        /// </summary>
        /// <returns></returns>
        Task<List<SensorItemDto>> GetDOChannelStatusAsync();

        /// <summary>
        /// 读取所有通道状态
        /// </summary>
        /// <returns></returns>
        Task<(bool DigitalInputRlt, List<RelayChannelItemDto> ChannelStatusList)> ReadDOAllChannelStatusAsync();


        /// <summary>
        /// 读取单个通道状态
        /// </summary>
        /// <param name="i_iCh">通道</param>
        /// <returns></returns>
        Task<(bool DigitalInputRlt, bool ChannelStatus)> ReadDOChannelStatusAsync(int i_iCh);

        /// <summary>
        /// 设置DO状态
        /// </summary>
        /// <param name="i_iCh">通道</param>
        /// <param name="value">值</param>
        /// <returns></returns>
        Task<bool> SetDOChannelStatusAsync(int i_iCh, bool value);
    }

}
